package org.jeecg.modules.nurse_user_orders_nurses.service.impl;

import org.jeecg.modules.nurse_user_orders_nurses.entity.NurseUserOrdersNurses;
import org.jeecg.modules.nurse_user_orders_nurses.entity.NurseUserOrdersNursesExecute;
import org.jeecg.modules.nurse_user_orders_nurses.mapper.NurseUserOrdersNursesExecuteMapper;
import org.jeecg.modules.nurse_user_orders_nurses.mapper.NurseUserOrdersNursesMapper;
import org.jeecg.modules.nurse_user_orders_nurses.service.INurseUserOrdersNursesService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
import java.util.Collection;
import java.util.Map;

/**
 * @Description: 订单分配
 * @Author: jeecg-boot
 * @Date: 2024-06-04
 * @Version: V1.0
 */
@Service
public class NurseUserOrdersNursesServiceImpl extends ServiceImpl<NurseUserOrdersNursesMapper, NurseUserOrdersNurses> implements INurseUserOrdersNursesService {

    @Autowired
    private NurseUserOrdersNursesMapper nurseUserOrdersNursesMapper;
    @Autowired
    private NurseUserOrdersNursesExecuteMapper nurseUserOrdersNursesExecuteMapper;

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delMain(String id) {
        nurseUserOrdersNursesExecuteMapper.deleteByMainId(id);
        nurseUserOrdersNursesMapper.deleteById(id);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delBatchMain(Collection<? extends Serializable> idList) {
        for (Serializable id : idList) {
            nurseUserOrdersNursesExecuteMapper.deleteByMainId(id.toString());
            nurseUserOrdersNursesMapper.deleteById(id);
        }
    }

    @Override
    public List<Map<String, Object>> listByWeChat(String nursesId) {
        return nurseUserOrdersNursesMapper.listByWeChat(nursesId);
    }

}
